﻿using System.Windows;
using System.Xml;
using ICSharpCode.AvalonEdit.Highlighting.Xshd;
using ICSharpCode.AvalonEdit.Highlighting;
using System.Windows.Media;
using IWMAG.Scripting.DevelopmentEnvironment.CodeCompletion;

namespace IWMAG.Scripting.DevelopmentEnvironment
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {

        internal DirectedAcyclicList<char> dawg;
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            XshdSyntaxDefinition xshd;
            using (XmlTextReader reader = new XmlTextReader("iwmag.xshd"))
            {
                xshd = HighlightingLoader.LoadXshd(reader);
            }

            dawg = new CodeCompletion.DirectedAcyclicList<char>();
            foreach (var item in (((xshd.Elements[4] as XshdRuleSet).Elements[3]) as XshdKeywords).Words)
            {    
                dawg.Add(item);
            }
            



           HighlightingManager.Instance.RegisterHighlighting("iwmag", null, HighlightingLoader.Load(xshd,HighlightingManager.Instance));

           var c = HighlightingManager.Instance.GetDefinition("iwmag");
            var k = new SimpleHighlightingBrush(Color.FromRgb(163,21,21));
            c.GetNamedColor("String").Foreground = k;
        }
    }
}
